(function (factory) {
	if (typeof define === 'function' && define.amd) {
		// AMD (Register as an anonymous module)
		define(['jquery'], factory);
	} else if (typeof exports === 'object') {
		// Node/CommonJS
		module.exports = factory(require('jquery'));
	} else {
		// Browser globals
		factory(jQuery);
	}
}(function ($) {

	var pluses = /\+/g;

	function encode(s) {
		return config.raw ? s : encodeURIComponent(s);
	}

	function decode(s) {
		return config.raw ? s : decodeURIComponent(s);
	}

	function stringifyCookieValue(value) {
		return encode(config.json ? JSON.stringify(value) : String(value));
	}

	function parseCookieValue(s) {
		if (s.indexOf('"') === 0) {
			s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
		}
		try {
			s = decodeURIComponent(s.replace(pluses, ' '));
			return config.json ? JSON.parse(s) : s;
		} catch (e) {
		}
	}

	function read(s, converter) {
		var value = config.raw ? s : parseCookieValue(s);
		return $.isFunction(converter) ? converter(value) : value;
	}

	var config = $.cookie = function (key, value, options) {
		if (arguments.length > 1 && !$.isFunction(value)) {
			options = $.extend({}, config.defaults, options);

			if (typeof options.expires === 'number') {
				var days = options.expires, t = options.expires = new Date();
				t.setMilliseconds(t.getMilliseconds() + days * 864e+5);
			}

			return (document.cookie = [
				encode(key), '=', stringifyCookieValue(value),
				options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
				options.path ? '; path=' + options.path : '',
				options.domain ? '; domain=' + options.domain : '',
				options.secure ? '; secure' : ''
			].join(''));
		}
		var result = key ? undefined : {},
			cookies = document.cookie ? document.cookie.split('; ') : [],
			i = 0,
			l = cookies.length;

		for (; i < l; i++) {
			var parts = cookies[i].split('='),
				name = decode(parts.shift()),
				cookie = parts.join('=');
			if (key === name) {
				result = read(cookie, value);
				break;
			}
			if (!key && (cookie = read(cookie)) !== undefined) {
				result[name] = cookie;
			}
		}
		return result;
	};

	config.defaults = {};

	$.removeCookie = function (key, options) {
		// Must not alter options, thus extending a fresh object...
		$.cookie(key, '', $.extend({}, options, {expires: -1}));
		return !$.cookie(key);
	};


	var HTML_ENCODE = {
		"&": "&amp;",
		"<": "&lt;",
		">": "&gt;",
		"'": "&",
		'"': "&quot;",
		' ': "&nbsp;",
		"\n": "<br/>"
	};
	window.html_encode = function (str, space, br) {
		if (!str || str.length === 0) return "";
		var reg;
		if (arguments.length > 1 && (space === false || space === undefined || space === 0)) {
			reg = br ? /&|<|>|'|"|\n/g : /&|<|>|'|"/g;
		} else {
			reg = br ? /&|<|>|'|"| |\n/g : /&|<|>|'|"| /g;
		}

		return str.replace(reg, function ($0) {
			return HTML_ENCODE[$0];
		});
	}
	window.html_decode = function (str) {
		if (!str || str.length === 0) return "";
		var s = str.replace(/&amp;/g, "&");
		s = s.replace(/&lt;/g, "<");
		s = s.replace(/&gt;/g, ">");
		s = s.replace(/&nbsp;/g, " ");
		s = s.replace(/&#39;/g, "\'");
		s = s.replace(/&quot;/g, "\"");
		s = s.replace(/<br\/>/g, "\n");
		return s;
	}


	var DT = window.DT = {};
	// DtGroup
	(function ($) {
		var allowedMethods = ["destroy", "setCheckedByValue", "setCheckedByIndex", "selectAll", "setMultipleCheckMode", "getValues", "getRawValues"];


		function clickFn2(refresh) {
			var $input = $(this);
			var $label = $input.parent();
			var $dtGroup = $input.closest(".dt-group");
			if ($dtGroup.hasClass("readonly")) {
				return;
			}
			var oldChecked = $label.hasClass("checked");

			var multipleCheck = $dtGroup.data("checkMode") === 'multiple';
			if (multipleCheck) {
				$dtGroup.find("label").each(function () {
					var $el = $(this);
					if ($el.find("input:checked").length) {
						$el.addClass("checked");
					} else {
						$el.removeClass("checked");
					}
				});
			} else {
				$dtGroup.find("label").each(function () {
					var $el = $(this);
					var input = $el.find("input")[0];
					if (this === $label[0]) {
						if (oldChecked && $dtGroup.data("allowCheckNone") !== undefined) {
							$el.removeClass("checked");
							input.checked = false;
						} else {
							$el.addClass("checked");
							input.checked = true;
						}
					} else {
						if (input.checked) {
							$el.removeClass("checked");
							input.checked = false;
						}
					}
				});
			}
			if (!refresh) {
				if (oldChecked && $dtGroup.data("allowCheckNone") !== undefined) {
					$label.removeClass("checked");
					$input[0].checked = false;
				}
			}

		}

		function clickFn() {
			clickFn2.call(this, false);
		}

		var DtGroup = function (el, options) {
			this.options = options;
			this.$el = $(el);
			var that = this;
			this.$el.find("input").click(clickFn);
			this.setMultipleCheckMode = function (isMultipleMode) {
				if (isMultipleMode) {
					that.$el.data("checkMode", 'multiple');
				} else {
					that.$el.data("checkMode", '');
					var el = that.$el.find("input:checked").eq(0);
					if (el[0]) {
						el[0].checked = true;
						clickFn2.call(el, true);
					}
				}
			};
			this.getValues = function (val) {
				return $.map(that.$el.find("input:checked"), function (el) {
					return el.value;
				});
			};
			this.getRawValues = function (val) {
				return $.map(that.$el.find("input:checked"), function (el) {
					return {id: el.value, text: (el.parentNode.innerText || "").replace(/^\s+|\s+$/, "")};
				});
			};
			this.setCheckedByValue = function (val) {
				if (that.$el.hasClass("readonly")) {
					return;
				}
				var el = that.$el.find("input").filter(function (i, el) {
					return el.value === val;
				});
				el[0].checked = true;
				clickFn2.call(el, true);
			};
			this.setCheckedByIndex = function (index) {
				if (that.$el.hasClass("readonly")) {
					return;
				}
				var el = that.$el.find(">*").eq(index).find("input");
				el[0].checked = true;
				clickFn2.call(el, true);
			}
			this.selectAll = function (checked) {
				if (that.$el.hasClass("readonly")) {
					return;
				}
				that.$el.find(">*").find("input").each(function (i, el) {
					el.checked = checked;
					clickFn2.call(el, true);
				});

			}
		};
		DtGroup.DEFAULTS = {};
		$.fn.dtGroup = function (option) {
			var value,
				args = Array.prototype.slice.call(arguments, 1);

			this.each(function () {
				var $this = $(this),
					data = $this.data('ditop.dtGroup'),
					options = $.extend({}, DtGroup.DEFAULTS, $this.data(),
						typeof option === 'object' && option);

				if (typeof option === 'string') {
					if ($.inArray(option, allowedMethods) < 0) {
						throw new Error("Unknown method: " + option);
					}
					if (!data) {
						return;
					}
					value = data[option].apply(data, args);
					if (option === 'destroy') {
						$this.removeData('ditop.dtGroup');
					}
				}
				if (!data) {
					$this.data('ditop.dtGroup', (data = new DtGroup(this, options)));
				}
			});
			if (this.length === 0) {
				return {};
			}
			return typeof value === 'undefined' ? this : value;
		};
	})(jQuery);

	(function () {


		DT.bindDtGroupEvent = function (ctx) {
			(ctx || $(document.body)).find(".dt-group").dtGroup();
		};
	})();

	$.extend(DT, {
		padingTB: function (el) {
			return (parseInt(el.css("padding-top")) || 0) + (parseInt(el.css("padding-bottom")) || 0)
		},
		padingLR: function (el) {
			return (parseInt(el.css("padding-left")) || 0) + (parseInt(el.css("padding-right")) || 0)
		},
		marginTB: function (el) {
			return (parseInt(el.css("margin-top")) || 0) + (parseInt(el.css("margin-bottom")) || 0)
		},
		marginLR: function (el) {
			return (parseInt(el.css("margin-left")) || 0) + (parseInt(el.css("margin-right")) || 0)
		}

	});


	DT.tag = {};
	DT.tag.d_group = function (args) {
		function attribIsTrue(attrib) {
			return attrib !== null && attrib !== undefined && attrib !== "false" && attrib !== false;
		}

		var html = [];
		var optArr = $.type(args.optArr) === 'array' ? args.optArr : null;
		var optIdKey = args.optIdKey || "id";
		var optTextKey = args.optTextKey || "text";
		var optCheckedKey = args.optCheckedKey || "checked";
		var textArr = $.type(args.optTexts) === 'array' ? args.optTexts : (args.optTexts || "").split(",");
		var valArr = $.type(args.optValues) === 'array' ? args.optValues : (args.optValues || "").split(",");
		var multiple = attribIsTrue(args.multiple);
		html.push("<div class=\"dt-group");
		if (args.cssClass) {
			html.push(" ", args.cssClass);
		}
		if (attribIsTrue(args.readonly)) {
			html.push(" readonly");
		}
		html.push("\"");
		if (args.cssStyle) {
			html.push(" style=\"", args.cssStyle, "\"");
		}
		if (args.id) {
			html.push(" id=\"", args.id, "\"");
		}
		if (attribIsTrue(args.allowCheckNone)) {
			html.push(" data-allow-check-none=\"\"");
		}
		if (multiple) {
			html.push(" data-check-mode=\"multiple\"");
		}
		html.push(">");

		if (optArr) {
			var checkFirst = false;
			if (attribIsTrue(args.checkFirst)) {
				var hasChecked = false;
				for (var i = 0; i < optArr.length; i++) {
					if (optArr[i][optCheckedKey]) {
						hasChecked = true;
						break;
					}
				}
				checkFirst = !hasChecked
			}
			for (var i = 0; i < optArr.length; i++) {
				var opt = optArr[i];
				var text = opt[optTextKey];
				var val = opt[optIdKey];
				html.push("<label class=\"checkbox");
				var checked = (i === 0 && checkFirst) || opt[optCheckedKey];
				if (checked) {
					html.push(" checked");
				}
				html.push("\"><input type=\"checkbox\" value=\"", val, "\"");
				if (checked) {
					html.push(" checked");
				}
				if (args.name) {
					html.push(" name=\"", args.name, "\"");
				}
				html.push("><s></s>", text, "</label>");
			}
		} else {
			var checkFirst = !args.checkValue && attribIsTrue(args.checkFirst);
			var checkedSet = {};
			if (args.checkValue) {
				if (multiple) {
					var arr = args.checkValue.split(",");
					for (var i = 0; i < arr.length; i++) {
						checkedSet[arr[i]] = true;
					}
				} else {
					checkedSet[args.checkValue] = true;
				}
			}
			for (var i = 0; i < textArr.length; i++) {
				var text = textArr[i];
				var val = valArr[i];
				html.push("<label class=\"checkbox");
				var checked = (i === 0 && checkFirst) || checkedSet[val];
				if (checked) {
					html.push(" checked");
				}
				html.push("\"><input type=\"checkbox\" value=\"", val, "\"");
				if (checked) {
					html.push(" checked");
				}
				if (args.name) {
					html.push(" name=\"", args.name, "\"");
				}
				html.push("><s></s>", (text), "</label>");
			}
		}
		html.push("</div>");
		return html.join("");
	};

	$.extend(template.defaults.imports, {
		d_group: function (v, args) {
			return DT.tag.d_group(args);
		},
		date: function (v, def) {
			return (v || "").replace(/ .*?$/, "") || def || "";
		},
		createdInfo: function (v, creationTime) {
			return "由 " + v.replace(/.*:/, "") + " 创建于 " + creationTime;
		},
		lastModifiedBy: function (v, lastModifiedTime) {
			return !v ? "" : "由 " + v.replace(/.*:/, "") + " 修改于 " + lastModifiedTime;
		}, modelInfo: function (data, clazz) {
			if (!data.creationTime) {
				return "";
			}
			var html = [];
			html.push('<div class="row update-area ', clazz, '">');
			html.push('<div class="col-md-12"><div class="well">');
			html.push('<div><label>创建信息:</label> 由<span>', (data.createdBy || "").replace(/.*:/, ""), '</span>创建于<span>', data.creationTime, '</span></div>');
			if (data.lastModifiedTime) {
				html.push('<div><label>修改信息:</label> 由<span>', (data.createdBy || "").replace(/.*:/, ""), '</span>修改于<span>', data.lastModifiedTime, '</span></div>');
			}
			html.push('</div></div>');
			return html.join("")
		}
	});

	/**
	 * 附件上传表单验证
	 */
	DT.Uploader = {
		validate: function (ctx) {
			var result = true;
			(ctx || $(document.body)).find("div.ditop-uploader").each(function () {
				var $ele = $(this), $uploader = $ele.data("uploader"),
					fileCount = $ele.data('fileCount') || 0, minFileNum = $ele.data("minFileNum"), stats = $uploader.getStats();
				if (stats.progressNum > 0) {
					result = false;
					$ele.find("span.status").html("文件正在上传, 请等待上传完毕后提交。").show();
				}
				if (fileCount < minFileNum) {
					result = false;
					$ele.find("span.status").html("请至少上传" + minFileNum + "个文件。").show();
				}
			});
			return result;
		}
	};
	/**
	 * utilities
	 * 工具类
	 */
	DT.utils = {
		"execute": function (text, url, data, cbfunc) {
			swal({
				title: "温馨提示", html: true, text: text,
				type: "warning", showCancelButton: true, confirmButtonColor: "#DD6B55",
				confirmButtonText: "确认操作", closeOnConfirm: false, showLoaderOnConfirm: true
			}, function () {
				swal.close();
				var index = layer.load(0, {time: 60 * 1000, shade: 0.08});
				$.ajax({
					url: url, data: data, dataType: 'json', type: 'post',
					success: function (resp) {
						layer.close(index);
						if (resp.success) {
							layer.msg('操作成功！', {anim: '5', offset: '50px'});
							cbfunc.apply(resp);
						} else {
							//swal("温馨提示",resp.msg);
							setTimeout(function () {
								swal("温馨提示", resp.msg);
							}, 100);
						}
					},
					error: function (xhr, error, exception) {
						layer.close(index);
						//swal("温馨提示","请求失败！","error");
						setTimeout(function () {
							swal("温馨提示", "请求失败！", "error");
						}, 100);
					}
				});
			});
		}, getDateRange: function (type) {
			var date = new Date();
			var d1, d2;
			if (type === '0') {// 今天
				d1 = this.getYMD(date);
				d2 = this.getYMD(date);
			} else if (type === '-1') { // 昨天
				date.setDate(date.getDate() - 1);
				d1 = this.getYMD(date);
				d2 = this.getYMD(date);
			} else if (type === '@-3') { // 最近三天
				d2 = this.getYMD(date);
				date.setDate(date.getDate() - 3);
				d1 = this.getYMD(date);
			} else if (type === '@-7') { // 最近七天
				d2 = this.getYMD(date);
				date.setDate(date.getDate() - 7);
				d1 = this.getYMD(date);
			} else if (type === '@-1m') { // 最近一个月
				d2 = this.getYMD(date);
				date.setMonth(date.getMonth() - 1, 0);
				d1 = this.getYMD(date);
			} else if (type === '1w') { // 本周
				date.setDate(date.getDate() - this.getWeek(date) + 1);
				d1 = this.getYMD(date);
				date.setDate(date.getDate() + 6);
				d2 = this.getYMD(date);
			} else if (type === '1m') { // 本月
				date.setDate(1);
				d1 = this.getYMD(date);
				date.setMonth(date.getMonth() + 1, 0);
				d2 = this.getYMD(date);
			} else if (type === '-1m') { // 上月
				date.setDate(0);
				d2 = this.getYMD(date);
				date.setDate(1);
				d1 = this.getYMD(date);
			} else if (type === '1y') { // 今年
				date.setMonth(0, 1);
				d1 = this.getYMD(date);
				date.setFullYear(date.getFullYear() + 1, 0, 0);
				d2 = this.getYMD(date);
			} else if (type === '-1y') { // 去年
				date.setMonth(0, 0);
				d2 = this.getYMD(date);
				date.setMonth(0, 1);
				d1 = this.getYMD(date);
			}
			return [d1, d2];
		}, getYMD: function (d) {
			return d.getFullYear() + "-" + pad(d.getMonth() + 1) + "-" + pad(d.getDate());

			function pad(d) {
				return d < 10 ? "0" + d : d;
			}
		}, getWeek: function (d) {
			return d.getDay() || 7;
		}
	};
// 对日期进行格式化
	Date.prototype.format = function (fmt) { //author: meizz
		var o = {
			"M+": this.getMonth() + 1,                 //月份
			"d+": this.getDate(),                    //日
			"h+": this.getHours(),                   //小时
			"m+": this.getMinutes(),                 //分
			"s+": this.getSeconds(),                 //秒
			"q+": Math.floor((this.getMonth() + 3) / 3), //季度
			"S": this.getMilliseconds()             //毫秒
		};
		if (/(y+)/.test(fmt))
			fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
		for (var k in o)
			if (new RegExp("(" + k + ")").test(fmt))
				fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
		return fmt;
	};

// dtFilter
	(function ($) {
		var allowedMethods = ["render", "getParams", "destroy"];

		var DtFilter = function (el, options) {
			this.options = options;
			this.$el = $(el);
		};
		DtFilter.DEFAULTS = {
			onFilterChange: $.noop,
			onFilterSave: $.noop
		};
		DtFilter.EVENTS = {
			'change.dt.filter': 'onFilterChange',
			'save.dt.filter': 'onFilterSave'
		};
		DtFilter.types = {
			">": "大于",
			">=": "大于等于",
			"<": "小于",
			"<=": "小于等于",
			"=": "等于",
			"!=": "不等于",
			"%=": "开头等于",
			"=%": "结尾等于",
			"!%=": "开头不等于",
			"!=%": "结尾不等于",
			"%": "包含",
			"!%": "不包含",
			"is": "是",
			"[]": "是",
			"()": "是",
			"[)": "是",
			"(]": "是"
		};
		DtFilter.prototype.trigger = function (name) {
			var args = Array.prototype.slice.call(arguments, 1);
			name += '.dt.filter';
			this.options[DtFilter.EVENTS[name]].apply(this.options, args);

			this.$el.trigger($.Event(name), args);
		};

		DtFilter.prototype.render = function (filters, nofify) {
			var that = this;
			var $el = this.$el;
			var old = $el.html();
			nofify = nofify !== false;
			if (!filters || !filters.length) {
				$el.empty();
				nofify && $el.html() !== old && that.trigger('change', that);
				return;
			}
			var html = ['<div class="filter-bar"><strong></strong>'];
			html.push('<ul class="list-inline">');

			$.each(filters, function (i, v) {
				html.push('<li><span class="btn btn-outline btn-xs"><span class="name">', v.name, "</span>");
				if (v.value || v.valueText) {
					html.push('<span class="filter-type">', DtFilter.types[v.type] || v.type, '</span><span class="text">', v.valueText || v.value, "</span>");
				}
				html.push(' <i class="remove fa fa-remove"></i></span>');
				html.push('<span class="badge badge-blue rounded"></span></li>');
			});

			html.push('</ul>');
			html.push('<span class="tools"><span  class="clearFilter"><a href="javascript:;">清空</a></span><span class="saveFilter hide">|<a href="javascript:;">保存为...</a></span></span>');
			html.push('</div>');
			$el.html(html.join(""));
			$el.find("li").each(function (i, li) {
				$(this).data("filter", filters[i].fileds);
			});
			$el.find(".saveFilter").click(function () {
				var condition = $el.find("li").map(function () {
					return $(this).data("filter")
				});
				that.trigger('save', condition);
			});
			$el.find(".remove").click(function () {
				$(this.parentNode.parentNode).remove();
				if (!$el.find("li").length) {
					$el.empty();
				}
				that.trigger('change', that, true);
			});
			$el.find(".clearFilter").click(function () {
				$el.empty();

				that.trigger('change', that, true);
			});
			nofify && $el.html() !== old && that.trigger('change', that);
		};
		DtFilter.prototype.getParams = function (prefix) {
			var $el = this.$el;
			var params = {};
			prefix = prefix || "";
			$el.find("li").map(function () {
				$.each($(this).data("filter"), function () {
					params[prefix + this.name] = this.value;
				});
			});
			return params;
		};
		DtFilter.prototype.hasParam = function () {
			return !!this.$el.html();
		};
		$.dtFilter = {
			generate: function (filterConfig, baseEl) {
				var filters = [];
				baseEl = $(baseEl || "body");
				if (baseEl.length === 0) {
					baseEl = $("body");
				}
				$.each(filterConfig, function (i, f) {
					var filter;
					if ($.type(f.key) === 'array') {
						f.el = f.el || [];
						f.value = f.value || [];
						var el0 = baseEl.find(f.el[0] || "#" + f.key[0]);
						if (el0.length === 0 && !f.el[0]) {
							el0 = baseEl.find("[name='" + f.key[0] + "']");
						}
						var el1 = baseEl.find(f.el[1] || "#" + f.key[1]);
						if (el1.length === 0 && !f.el[1]) {
							el1 = baseEl.find("[name='" + f.key[1] + "']");
						}
						var value0 = el0.val();
						var value1 = el1.val();
						if (value0 || value1) {
							filter = {
								"fileds": [{"name": f.key[0], "value": value0}, {"name": f.key[1], "value": value1}],
								"name": f.name,
								"type": f.type || "[]"
							};
							if (value0 === value1) {
								filter.value = f.value[3] || "$1";
								filter.type = "是";

							} else if (value0 && value1) {
								filter.value = f.value[1] || "$1 - $2";
							} else if (value0) {
								filter.value = f.value[0] || "$1";
							} else {
								filter.value = f.value[2] || "$2";
							}
							filter.value = filter.value.replace("$1", value0 || "").replace("$2", value1 || "");
							filters.push(filter);
						}
						return;
					}

					var el = baseEl.find(f.el || "#" + f.key);
					if (el.length === 0 && !f.el) {
						el = baseEl.find("[name='" + f.key + "']");
					}
					if (el.length) {
						var value = el.val();
						if (value) {
							filter = {
								"fileds": [{"name": f.key, "value": value}],
								"name": f.name,
								"type": f.type || "%",
								"value": value
							};

							if ($.type(f.name) === 'object') {
								filter.name = f.name[value];
								filter.type = f.type || "is";
								filter.value = "";
							} else if ($.type(f.mapping) === 'object') {
								filter.type = f.type || "is";
								var valueText = f.mapping[value];
								if ($.type(valueText) === 'object') {
									valueText = f.mappingKey ? valueText[f.mappingKey] : valueText["dataValue"] || valueText["data_value"] || valueText["text"]
								}
								if (f.name) {
									filter.valueText = valueText;
								} else {
									filter.name = valueText;
									filter.value = "";
								}
							}
							filters.push(filter);
						}
					}
				});
				return filters;
			},
			reset: function (filterConfig, baseEl) {
				var filters = [];
				baseEl = $(baseEl || "body");
				if (baseEl.length === 0) {
					baseEl = $("body");
				}
				$.each(filterConfig, function (i, f) {
					var filter;
					if ($.type(f.key) === 'array') {
						f.el = f.el || [];
						f.value = f.value || [];
						var el0 = baseEl.find(f.el[0] || "#" + f.key[0]);
						if (el0.length === 0 && !f.el[0]) {
							el0 = baseEl.find("[name='" + f.key[0] + "']");
						}
						var el1 = baseEl.find(f.el[1] || "#" + f.key[1]);
						if (el1.length === 0 && !f.el[1]) {
							el1 = baseEl.find("[name='" + f.key[1] + "']");
						}
						el0.val("");
						el1.val("");
						return;
					}

					var el = baseEl.find(f.el || "#" + f.key);
					if (el.length === 0 && !f.el) {
						el = baseEl.find("[name='" + f.key + "']");
					}
					el.val("");
				});
				return filters;
			}
		};
		$.fn.dtFilter = function (option) {
			var value,
				args = Array.prototype.slice.call(arguments, 1);

			this.each(function () {
				var $this = $(this),
					data = $this.data('ditop.dtFilter'),
					options = $.extend({}, DtFilter.DEFAULTS, $this.data(),
						typeof option === 'object' && option);

				if (typeof option === 'string') {
					if ($.inArray(option, allowedMethods) < 0) {
						throw new Error("Unknown method: " + option);
					}
					if (!data) {
						return;
					}
					value = data[option].apply(data, args);
					if (option === 'destroy') {
						$this.removeData('ditop.dtFilter');
					}
				}
				if (!data) {
					$this.data('ditop.dtFilter', (data = new DtFilter(this, options)));
				}
			});
			if (this.length === 0 && option === 'getParams') {
				return {};
			}
			return typeof value === 'undefined' ? this : value;
		};
	})(jQuery);

// DtTreeAction
	(function ($) {
		var allowedMethods = ["destroy"];

		var DtTreeAction = function (el, options) {
			this.options = options;
			this.$el = $(el);
			if (!options.targetTree) {
				throw new Error("no data-target attribute");
			}
			this.treeId = $(options.targetTree).attr("id");

			render(this);
			initEvent(this);

			function render(that) {
				if (!that.$el.find(".dt-actions")[0]) {
					if (that.$el.hasClass("dt-right")) {
						that.$el.append('<div class="dt-actions"><a class="btn btn-link dt-treeAction"><i></i></a></div>')
					} else {
						that.$el.prepend('<div class="dt-actions"><a class="btn btn-link dt-treeAction"><i></i></a></div>')
					}
				}
			}

			function initEvent(that) {
				that.$el.find(".dt-treeAction").click(function () {
					if (that.$el.hasClass("dt-fold")) {
						that.$el.removeClass("dt-fold");
						$.fn.zTree.getZTreeObj(that.treeId).expandAll(false);
					} else {
						that.$el.addClass("dt-fold");
						$.fn.zTree.getZTreeObj(that.treeId).expandAll(true);
					}
				});
			}


		};
		DtTreeAction.DEFAULTS = {};
		$.fn.dtTreeAction = function (option) {
			var value,
				args = Array.prototype.slice.call(arguments, 1);

			this.each(function () {
				var $this = $(this),
					data = $this.data('ditop.dtTreeAction'),
					options = $.extend({}, DtTreeAction.DEFAULTS, $this.data(),
						typeof option === 'object' && option);

				if (typeof option === 'string') {
					if ($.inArray(option, allowedMethods) < 0) {
						throw new Error("Unknown method: " + option);
					}
					if (!data) {
						return;
					}
					value = data[option].apply(data, args);
					if (option === 'destroy') {
						$this.removeData('ditop.DtTreeAction');
					}
				}
				if (!data) {
					$this.data('ditop.DtTreeAction', (data = new DtTreeAction(this, options)));
				}
			});
			if (this.length === 0) {
				return {};
			}
			return typeof value === 'undefined' ? this : value;
		};
	})(jQuery);

// DtLayout
	(function ($) {
		var allowedMethods = ["destroy", "resize"];

		var DtLayout = function (el, options) {
			this.options = options;
			this.$el = $(el);
			this.elOffset = {left: 0, top: 0};
			this.resize = function () {
				this.elOffset = this.$el.offset();
				// var w = this.$el.width() - this.$left.outerWidth(true) - this.$dtResize.outerWidth(true) - DT.padingLR(this.$right) - 2;
				// this.$right.width(w);
			};

			init(this);
			initEvent(this);

			function init(that) {
				that.$left = that.$el.find(options.left);
				that.$right = that.$el.find(options.right);
				that.$dtResize = that.$el.find(".dtResize");
				that.$dtResize_drag = that.$el.find(".dtResize_drag");
				if (options.leftWidth) {
					that.$left.width(options.leftWidth);
				}

				if (!that.$dtResize[0]) {
					that.$dtResize = $('<div class="dtResize"></div>').insertAfter(that.$left);
				}
				if (!that.$dtResize_drag[0]) {
					that.$dtResize_drag = $('<div class="dtResize_drag ' + that.options.dragClass + '"></div>').insertAfter(that.$dtResize);
				}

				that.resize();
			}

			function initEvent(that) {
				that.$dtResize.on("mousedown", function (e) {
					if (!that.sliderMoving) {
						that.$dtResize_drag.css({left: mousePosition(that, e).x - 2, display: "block"});
					}
					that.$el.addClass("dragging");
					that.sliderMoving = true;
					that.$el.css("cursor", "e-resize");
				});

				that.$el.on({
					mousemove: function (e) {
						if (that.sliderMoving) {
							sliderGhostMoving(that, e);
						}
					}, mouseup: function (e) {
						if (that.sliderMoving) {
							that.sliderMoving = false;
							sliderHorizontalMove(that, e);
							that.$el.css("cursor", "default");
							that.$el.removeClass("dragging");
						}
					}
				});
			}

			function mousePosition(that, e) {
				var xx = e.originalEvent.x || e.originalEvent.layerX || 0;
				var yy = e.originalEvent.y || e.originalEvent.layerY || 0;
				return {x: xx - that.elOffset.left, y: yy - that.elOffset.top};
			}

			function getElCoordinate(dom) {
				var t = dom.offsetTop;
				var l = dom.offsetLeft;
				dom = dom.offsetParent;
				while (dom) {
					t += dom.offsetTop;
					l += dom.offsetLeft;
					dom = dom.offsetParent;
				}
				return {top: t, left: l};
			}

			//分隔条幽灵左右拖动(mousemove)
			function sliderGhostMoving(that, e) {
				that.$dtResize_drag.css({
					left: Math.max(that.options.minWidth, Math.min(that.options.maxWidth, mousePosition(that, e).x - 2)),
				});
			}

			//完成分隔条左右拖动(mouseup)
			function sliderHorizontalMove(that, e) {
				var lWidth = getElCoordinate(that.$dtResize_drag[0]).left - that.elOffset.left - 2;
				//var rWidth = that.$el.width() - lWidth - 8;
				that.$left.css("width", lWidth + "px");
				that.resize();
				//that.$left.closest(".scroller-wrapper").css("width", lWidth + "px");
				//that.$right.css("width", rWidth + "px");
				that.$dtResize_drag.css("display", "none");
			}
		};
		DtLayout.DEFAULTS = {
			left: ">div:first-child",
			right: ">div:last-child",
			// leftWidth: 360,
			minWidth: 160,
			maxWidth: 800,
			dragClass: ''
		};
		$.fn.dtLayout = function (option) {
			var value,
				args = Array.prototype.slice.call(arguments, 1);

			this.each(function () {
				var $this = $(this),
					data = $this.data('ditop.dtLayout'),
					options = $.extend({}, DtLayout.DEFAULTS, $this.data(),
						typeof option === 'object' && option);

				if (typeof option === 'string') {
					if ($.inArray(option, allowedMethods) < 0) {
						throw new Error("Unknown method: " + option);
					}
					if (!data) {
						return;
					}
					value = data[option].apply(data, args);
					if (option === 'destroy') {
						$this.removeData('ditop.dtLayout');
					}
				}
				if (!data) {
					$this.data('ditop.dtLayout', (data = new DtLayout(this, options)));
				}
			});
			if (this.length === 0) {
				return {};
			}
			return typeof value === 'undefined' ? this : value;
		};
	})(jQuery);

	!function ($) {
		var DtPopover = function (element, options) {
			this.init('dtPopover', element, options);
			var el = this.$element;
			el.on('hide.bs.dtPopover.dt', function () {
				$(".popover-mask").remove();
			});
			el.on('shown.bs.dtPopover.dt', function () {
				var $mask = $('<div class="popover-mask"></div>');
				$("body").append($mask);
				$mask.click(function (e) {
					$(".popover-mask").remove();
					el.dtPopover('destroy');
					var targetEl = document.elementFromPoint(e.pageX - document.body.scrollLeft, e.pageY - (window.pageYOffset || document.documentElement.scrollTop));
					if (el[0] !== targetEl) {
						$(targetEl).trigger("click");
					}
				});
			});

		};
		DtPopover.prototype = $.extend({}, $.fn.popover.Constructor.prototype)
		DtPopover.prototype.constructor = DtPopover;

		function Plugin(option) {
			return this.each(function () {
				var $this = $(this);
				var data = $this.data('bs.dtPopover')
				var options = typeof option === 'object' && option;
				if (!data && /destroy|hide/.test(option)) return
				if (!data) $this.data('bs.dtPopover', (data = new DtPopover(this, options)))
				if (typeof option === 'string') data[option]()
			})
		}

		$.fn.dtPopover = Plugin
		$.fn.dtPopover.Constructor = DtPopover

	}(jQuery);
}))
;
var loadEs6Tmpl = function (url) {
	var rx_escapable = /[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
	var meta = { // table of character substitutions
		"\b": "\\b",
		"\t": "\\t",
		"\n": "\\n",
		"\f": "\\f",
		"\r": "\\r",
		"\"": "\\\"",
		"\\": "\\\\"
	};

	function quoteStr(string) {
		rx_escapable.lastIndex = 0;
		return rx_escapable.test(string)
			? "\"" + string.replace(rx_escapable, function (a) {
			var c = meta[a];
			return typeof c === "string"
				? c
				: "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4);
		}) + "\""
			: "\"" + string + "\"";
	}

	jQuery.ajax({
		url: url,
		dataType: "html",
		cache: false,
		sync: true
	}).done(function (text) {
		$.globalEval(text.replace(/`\s*([^`]+)\s*`/g, function ($0, $1) {
			return quoteStr($1)
		}))
	});
}
var Utils = function () {
	var util = {};
	util.TIMEOUT = 60 * 1000; // 60秒;常量不能通过代码修改

	util.startPageLoading = function (options) {
		options = options || {};
		options.animate = options.animate !== false;
		App.startPageLoading(options);
	}
	util.stopPageLoading = function () {
		App.stopPageLoading();
	}

	var _errorFn = function (xhr, error, exception) {
		App.stopPageLoading();
		swal("温馨提示", error);
	}
	util.post = function (param, success, error) {
		if (!param) {
			throw "第一个参数param必传！";
		}
		var successFn = param.success || success;
		var errorFn = param.error || error || _errorFn;
		$.ajax({
			url: param.url,
			data: param.data,
			dataType: 'json',
			type: 'post',
			timeout: param.timeout || util.TIMEOUT,
			success: function (data, status, xhr) {
				if (data.success) {
					successFn && successFn(data);
				} else {
					errorFn && errorFn(xhr, data.msg, false);
				}
			},
			error: function (xhr, error, exception) {
				if ((!error || "error" === error) && xhr !== null && xhr.status !== 200) {
					error = "网络请求失败:" + xhr.status;
				}
				error = error || exception || "操作失败";
				errorFn && errorFn(xhr, error, exception);
			}
		});
	};

	var _errorFn2 = function (xhr, error, exception) {
		swal("温馨提示", error);
	}
	util.postWithLoading = function (param, success, error) {
		if (!param) {
			throw "第一个参数param必传！";
		}
		var successFn = param.success || success;
		var errorFn = param.error || error || _errorFn2;
		util.startPageLoading();
		$.ajax({
			url: param.url,
			data: param.data,
			dataType: 'json',
			type: 'post',
			timeout: param.timeout || util.TIMEOUT,
			success: function (data, status, xhr) {
				util.stopPageLoading();
				if (data.success !== false) {
					successFn && successFn(data);
				} else {
					errorFn && errorFn(xhr, data.msg, false);
				}
			},
			error: function (xhr, error, exception) {
				util.stopPageLoading();
				if ((!error || "error" === error) && xhr !== null && xhr.status !== 200) {
					error = "网络请求失败:" + xhr.status;
				}
				error = error || exception || "操作失败";
				errorFn && errorFn(xhr, error, exception);
			}
		});
	};

	if (window.toastr) {
		toastr.options.hideDuration = 0;
	}

	var toast = function (type, message, title, options) {

		if (typeof message === "object") {
			options = message;
			message = options.message;
			title = options.title;
		} else if (typeof title === "object") {
			options = title;
			title = options.title;
		}
		options = $.extend({}, {
			closeButton: true,
			positionClass: "toast-top-center",
			showDuration: 1000,
			hideDuration: 1000,
			timeOut: 3000
		}, options);
		if (options.clearPrevAll) {
			toastr.clear();
			setTimeout(function () {
				toastr[type](message, title, options);
			}, 125)
		} else {
			toastr[type](message, title, options);
		}
	};
	util.clearToasts = function () {
		toastr.clear()
	};
	util.toast = function (type, message, title, options) {
		toast(type, message, title, options);
	};
	util.toastInfo = function (message, title, options) {
		toast("info", message, title, options);
	};
	util.toastSuccess = function (message, title, options) {
		toast("success", message, title, options);
	};
	util.toastWarning = function (message, title, options) {
		toast("warning", message, title, options);
	};
	util.toastError = function (message, title, options) {
		toast("error", message, title, options);
	};


	// confirm方法 两个参数必传
	util.confirm = function (param, callback) {
		if (!param) {
			throw "第一个参数param必传！";
		}
		if (!callback) {
			throw "第二个参数callback必传！";
		}
		if (typeof param === "string") {
			swal({
				title: "温馨提示", // 标题
				text: param, // 内容
				type: "warning", // 类型
				showCancelButton: true,
				closeOnConfirm: false,
				confirmButtonColor: "#DD6B55",
				confirmButtonText: "确定",
				cancelButtonText: "取消"
			}, callback);
		} else {
			swal({
				title: param.title || "温馨提示",
				text: param.text,
				type: "warning",
				html: param.html || false, // true: 解析title标题和text中的html字符串
				showCancelButton: true,
				closeOnConfirm: false,
				confirmButtonColor: "#DD6B55",
				confirmButtonText: param.confirmButtonText || "确定",
				cancelButtonText: param.cancelButtonText || "取消"
			}, callback);
		}
	}
	// 打开弹出框 ; param参数必传
	util.openBox = function (config, callback, subWinCallback) {
		if (!config) {
			throw "第一个参数config必传！";
		}
		callback = callback || config.callback;
		subWinCallback = subWinCallback || config.subWinCallback;
		var ctx = config.ctx || window;
		var url = config.url || "";
		if (window.dtLayerIndex) {
			var deep = 0;
			var win = window;
			while (win !== ctx) {
				deep++;
				win = ctx.parent;
			}
			url = url + "#" + window.dtLayerIndex + "." + deep;
		}
		var area = config.area || ['760px', '300px'];
		var cw = document.documentElement.clientWidth;
		if (cw > 1368) {
			var w = parseInt(area[0]) * cw / 1368;
			area[0] = Math.floor(w || 100) + "px";
		}
		return ctx.layer.open({
			title: config.title,
			type: 2,
			area: area,
			//fixed : false, //不固定
			fixed: true,
			scrollbar: false,
			maxmin: config.maxmin === true,
			content: url,
			anim: -1,
			moving: function (layero) {
				if (ctx.select2LayerMovingCallback) {
					ctx.select2LayerMovingCallback(layero)
				}
			},
			resizing: function (layero) {
				if (ctx.select2LayerResizingCallback) {
					ctx.select2LayerResizingCallback(layero)
				}
			},
			success: function (layero, index) {
				try {
					var subWin = ctx.layer.getContentWindow(index);
					subWin.dtLayerIndex = index
					subWin.dtLayerCallback = subWinCallback
				} catch (e) {
				}
				if (config.autoHeight) {
					ctx.layer.iframeAuto(index, config.autoHeight || $(window).height() * 0.85);
				}
				callback && callback(layero, index, subWin);
			}
		});
	}
	util.appendTifilter = function (el, url) {
		var htmlEl = $.type(el) === 'object' && (el.nodeType || el.length && el[0].nodeType);
		var filter = undefined;
		if (htmlEl) {
			filter = $(el).attr("data-ti-filter");
		}

		if (!filter) {
			filter = $("li.active a[data-ti-filter]").attr("data-ti-filter");
		}
		return !filter || "all" === filter ? url : url + (url.indexOf("?") >= 0 ? "&" : "?") + "_ti_filter=" + (filter || "")
	}

	!function () {

		util.treeNodesToList = function (nodes, childKey, arrList) {
			$.each(nodes, function (index, item) {
				arrList.push(item.data);
				var children = item[childKey];
				if (children && children.length) {
					util.treeNodesToList(children, childKey, arrList);
				}
			});
			return arrList;
		};

		util.listToTree = function (arr, idKey, pIdKey, childKey, deepCopy) {
			var i, l;
			if (Object.prototype.toString.apply(idKey) === "[object Object]") { //
				var config = idKey;
				idKey = config.idKey || "id";
				pIdKey = config.pIdKey || "pid";
				childKey = config.childKey || "children";
			} else {
				idKey = idKey || "id";
				pIdKey = pIdKey || "pid";
				childKey = childKey || "children";
			}
			if (!idKey || idKey === "" || !arr) return [];

			if (Object.prototype.toString.apply(arr) === "[object Array]") { // 是数组
				arr = deepCopy ? JSON.parse(JSON.stringify(arr)) : arr;
				var r = [];
				var tmpMap = {};
				for (i = 0, l = arr.length; i < l; i++) {
					tmpMap[arr[i][idKey]] = arr[i];
				}
				for (i = 0, l = arr.length; i < l; i++) {
					if (tmpMap[arr[i][pIdKey]] && arr[i][idKey] !== arr[i][pIdKey]) {
						if (!tmpMap[arr[i][pIdKey]][childKey])
							tmpMap[arr[i][pIdKey]][childKey] = [];
						tmpMap[arr[i][pIdKey]][childKey].push(arr[i]);
					} else {
						r.push(arr[i]);
					}
				}
				return r;
			} else {
				return [arr];
			}
		};

		var _visitFn = function (fn, childKey, prefix) {
			var visitFn = function (result, data, depth, _prefix, parent) {
				for (var i = 0; i < data.length; i++) {
					var item = data[i];
					var position = i === data.length - 1 ? 1 : i === 0 ? -1 : 0;
					result.push(fn(item, depth, _prefix, parent, position));
					var children = item[childKey];
					if (children && children.length) {
						visitFn(result, children, depth + 1, _prefix + "" + prefix, item);
					}
				}
			};
			return visitFn;
		};
		/**
		 *
		 * @param arr
		 * @param fn function(item,depth,prefix,parent,position)
		 * @param idKey
		 * @param pIdKey
		 * @param prefix
		 * @returns {Array}
		 */
		util.visitTreeList = function (arr, fn, idKey, pIdKey, prefix, deepCopy) {
			var data = util.listToTree(arr, idKey, pIdKey, "__children", deepCopy === undefined ? true : deepCopy);
			var result = [];
			if (data && data.length) {
				_visitFn(fn, "__children", prefix)(result, data, 0, "");
			}
			return result;
		};
		util.visitTreeNodes = function (nodes, fn, childKey, prefix) {
			var result = [];
			if (nodes && nodes.length) {
				_visitFn(fn, childKey, prefix)(result, nodes, 0, "", 0);
			}
			return result;
		};
		/**
		 *
		 * @param zTreeObj
		 * @param nodes
		 * @param fn function(item,depth,prefix,parent,position)
		 * @param prefix
		 * @returns {Array}
		 */
		util.visitZTreeNodes = function (zTreeObj, nodes, fn, prefix) {
			var childKey = zTreeObj.setting.data.key.children;
			if (Object.prototype.toString.apply(nodes) === "[object Function]") {
				prefix = fn;
				fn = nodes;
				nodes = zTreeObj.getNodes();
			}
			var result = [];
			if (nodes && nodes.length) {
				_visitFn(fn, childKey, prefix)(result, nodes, 0, "", 0);
			}
			return result;
		};

		function toSelectFn(id, pid, idKey, nameKey, dataKey, edit, showAll) {
			var nameFn = Object.prototype.toString.apply(nameKey) === "[object Function]" ? nameKey : function (item, selected) {
				return item[nameKey] + (selected ? " √" : "");
			};
			var dataFn = Object.prototype.toString.apply(dataKey) === "[object Function]" ? dataKey : dataKey ? function (item) {
				return item[dataKey];
			} : function (item) {
				return item;
			};

			var selfPath = {};
			if (id !== null && id !== "" && id !== undefined) {
				selfPath[id] = 1;
			}
			if (edit) {
				if (showAll === undefined) {
					showAll = false;
				}
				return function (item, depth, prefix, parent, position) {
					var data = dataFn(item), idVal = data[idKey], attribs = idVal === pid ? " selected" : "";
					var ok = true;
					if (selfPath[idVal]) {
						if (!showAll) {
							return "";
						}
						attribs += " disabled";
					} else if (parent) {
						if (selfPath[dataFn(parent)[idKey]]) {
							if (!showAll) {
								return "";
							}
							attribs += " disabled";
							selfPath[idVal] = 1;
						}
					}
					prefix = prefix ? prefix + (position === 1 ? "└─ " : "├─ ") : "";
					return '<option value="' + idVal + '"' + attribs + '>' + prefix + nameFn(data, idVal === pid) + '</option>';
				}
			} else {
				return function (item, depth, prefix, parent, position) {
					var data = dataFn(item), idVal = data[idKey], attribs = idVal === pid ? " selected" : "";
					prefix = prefix ? prefix + (position === 1 ? "└─ " : "├─ ") : "";
					return '<option value="' + idVal + '"' + attribs + '>' + prefix + nameFn(data) + '</option>';
				};
			}
		}

		util.zTreeNodesToSelect = function (zTreeObj, id, pid, options) {
			var idKey = options.idKey || "id";
			var nameKey = options.nameKey || "name";
			var showAll = options.showAll;
			var edit = options.edit;
			var nodes = options.nodes || zTreeObj.getNodesByFilter(function (node) {
				return node.level === 1;
			}, false);
			var fn = toSelectFn(id, pid, idKey, nameKey, null, edit, showAll);
			return Utils.visitZTreeNodes(zTreeObj, nodes, fn, "　");
		};

		util.treeNodesToSelect = function (nodes, id, pid, options) {
			var idKey = options.idKey || "id";
			var nameKey = options.nameKey || "name";
			var dataKey = options.dataKey;
			var childKey = options.childKey || "subNodes";
			var showAll = options.showAll;
			var edit = options.edit;
			return Utils.visitTreeNodes(nodes, toSelectFn(id, pid, idKey, nameKey, dataKey, edit, showAll), childKey, "　");
		};
	}();

	util.arrayToMap = function (arr, idKey, valKey) {
		var m = {}
		var valueFn = Object.prototype.toString.apply(valKey) === "[object Function]" ? valKey : Object.prototype.toString.apply(valKey) === "[object String]" ? function (item) {
			return item[valKey];
		} : valKey === undefined ? function (item) {
			return item;
		} : function () {
			return valKey;
		};

		$.each(arr, function (i, o) {
			m[o[idKey]] = valueFn(o);
		});
		return m;
	}
	util.setChecked = function (checked, name, ctxEl) {
		ctxEl = $(ctxEl || "body")
		ctxEl.find("input[name='" + name + "']").each(function (i, e) {
			e.checked = !!checked;
		})
	};

	util.toggleChecked = function (name, ctxEl) {
		ctxEl = $(ctxEl || "body")
		ctxEl.find("input[name='" + name + "']").each(function (i, e) {
			e.checked = !e.checked;
		})
	};

	return util;
}();

(function ($) {
	var DEFAULTS = {
		beforeSerialize: "_dtBeforeSerialize",
		ignore: ":hidden:not(.needValidate)"
	}
	$.fn.extend({
		validateForm: function (option, successCallback) {
			var $this = $(this);

			var options = $.extend({}, DEFAULTS, $this.data(), typeof option === 'object' && option);

			var formValidate, $form = $(this), opt = {
				errorElement: 'span', errorClass: 'help-block help-block-error',
				errorPlacement: function (error, element) {
					var icon = $(element).parent('.input-icon').children('i');
					icon.removeClass('fa-check').addClass("fa-warning");
					icon.attr("data-original-title", error.text()).tooltip({'container': 'body'});
				},
				highlight: function (element) {
					$(element).closest('.dt-pair,.form-group').addClass('has-error');
				},
				unhighlight: function (element) {
					$(element).closest('.dt-pair,.form-group').removeClass('has-error');
				},
				success: function (label, element) {
					var icon = $(element).parent('.input-icon').children('i');
					$(element).closest('.dt-pair,.form-group').removeClass('has-error');//.addClass('has-success');
					icon.removeClass("fa-warning").addClass("fa-check");
				}
			};

			if (option && typeof (option) === "object") {
				$.extend(opt, option);
			}
			opt.ignore = options.ignore;
			// Fix input placeholder issue for IE8 and IE9 */
			$form.find('input, textarea').placeholder();

			formValidate = $(this).validate(opt);
			formValidate.doSubmit = function () {
				var submitOptions = {
					type: 'post',
					beforeSubmit: function () {
						$form.find('[placeholder]').each(function () {
							var input = $(this);
							if (input.val() === input.attr('placeholder')) {
								input.val('');
							}
						});
						if (!formValidate.form() || !DT.Uploader.validate($form)) {
							Utils.toastWarning("验证失败, 请检查输入内容!", {clearPrevAll: true});
							return false;
						}
						if (Object.prototype.toString.apply(window[options.customValidate]) === "[object Function]") {
							if (!window[options.customValidate].call($form[0], formValidate)) {
								Utils.toastWarning("验证失败, 请检查输入内容!", {clearPrevAll: true});
								return false;
							}
						}

						Utils.startPageLoading();
					},
					success: function (data, textStatus, jqXHR) {
						Utils.stopPageLoading();
						if (data.success) {
							top.Utils.toastSuccess("保存成功！");
							successCallback && successCallback(data);
						} else {
							swal("温馨提示", data.msg);
						}
					},
					error: function (xhr, textStatus, errorThrown) {
						Utils.stopPageLoading();
						if ((!textStatus || "error" === textStatus) && xhr !== null && xhr.status !== 200) {
							textStatus = "网络请求失败:" + xhr.status;
						}
						textStatus = textStatus || errorThrown || "操作失败";
						swal("温馨提示", textStatus);
					}
				};
				if (Object.prototype.toString.apply(window[options.beforeSerialize]) === "[object Function]") {
					submitOptions.beforeSerialize = window[options.beforeSerialize];
				} else {
					submitOptions.beforeSerialize = function () {
						$.each($form.find("input.uppercase"), function (i, el) {
							$(el).val($(el).val().toUpperCase());
						});
					};
				}
				$form.ajaxSubmit(submitOptions);
			};
			return formValidate;
		}
	});
}(jQuery));

var snippets = {
	bootstrapTable: {
		valid_formatter: function (value, row, index) {
			if (value === '1') {
				//return '<span class="label rounded-4 label-primary">已启用</span>';
				//return '<span class="label rounded-4 label-primary status-edit" id="'+row.bitemId+'" valid="'+row.valid+'">已启用</span> ';
				return "";
			} else {
				//return '<span class="label rounded-4 label-danger status-edit" id="'+row.bitemId+'" valid="'+row.valid+'">已禁用</span>';
				return '<span class="badge-disabled">已禁用</span>';
			}
		},
		status_clickFn: function (el, oldValid, callback) {
			el = $(el);
			var dtPopover = el.dtPopover({
				title: '修改记录状态为：',
				container: 'body',
				placement: 'left',
				trigger: 'click',
				animation: false,
				singleton: true,
				popOut: true,
				html: true,
				content: '<div class="btn-group">' +
				'<a class="btn btn-sm btn-danger modifyStatus" data-valid="0" >禁用</a>' +
				'<a class="btn btn-sm btn-success modifyStatus" data-valid="1">启用</a>' +
				' </div>'
			});
			el.off('shown.bs.dtPopover.2').on('shown.bs.dtPopover.2', function () {
				el.data('bs.dtPopover').$tip.find(".modifyStatus").click(function () {
					el.dtPopover('destroy');
					var valid = $(this).attr("data-valid");
					if (oldValid !== valid) {
						callback && callback(valid);
					}
				});
			});
			el.dtPopover("show");
		}

	}
}

jQuery(function () {
	$(".tree-actions").dtTreeAction();
	DT.bindDtGroupEvent($(document.body));
 	if ($.fn.TouchSpin) {
		$(".touchSpin").TouchSpin();
	}
		$(".btnCloseLayer").each(function (i, e) {
		$(e).click(function () {
			layer.closeCurrent(window);
		});
	});
	$(".ditop-form-bind form").each(function (i, e) {
		var $form = $(this);
		var formValidate = $form.validateForm({}, function (data) {
			layer.closeCurrent(window);
			window.dtLayerCallback && window.dtLayerCallback(data);
		});
		$form.submit(function () {
			formValidate.doSubmit();
			return false;
		});
		$("#saveBtn").on("click", function () {
			$form.submit();
		});
	});

	$(".setdate [data-diff-type]").click(function () {
		var ds = DT.utils.getDateRange($(this).attr("data-diff-type"));
		$("#lastLogin1").val(ds[0]);
		$("#lastLogin2").val(ds[1]);
	});

	if ($.fn.datepicker) {
		$('.date-picker').datepicker({
			language: "zh-CN", clearBtn: true,
			autoclose: true
		});
	}
})